import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';

import { AppComponent } from './app.component';
import { HeroListComponent } from './hero-list/hero-list.component';
import { HeroDetailComponent } from './hero-detail/hero-detail.component';
import { LoggerService } from './services/loggerService'
import { HeroService } from './services/heroService'

@NgModule({
  declarations: [
    AppComponent,
    HeroListComponent,
    HeroDetailComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule
  ],
  providers: [
    LoggerService,
    {
      provide: HeroService,
      useFactory: (logger: LoggerService): HeroService => {
        return new HeroService(logger);
      },
      deps: [LoggerService],
    }
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }
